package com.guestbook.dao.impl;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.guestbook.dao.AdminDAO;
import com.guestbook.javabeans.Admin;
import com.tools.OracleUtil;

public class AdminDAOJdbc implements AdminDAO {
	private static final String SELECT_ADMIN_SQL="select * from guestbook02_admin where username=? and password=?";
	OracleUtil db=null;
	public AdminDAOJdbc(){
		db=new OracleUtil("java:/comp/env/jdbc/ds_mysql");
		db.init();
	}
	public Admin getAdmin(String username, String password) {
		String params[]={username, password};
		List list=(List)db.query(SELECT_ADMIN_SQL, params, new BeanListHandler(Admin.class));
		if(list.size()>=1){
			return (Admin)list.get(0);
		}else{
			return null;
		}
	}
}
